<template>
  <div class="home">
    <input type="text" v-model="text" />
    <button @click="tijiao">提交</button>
    <p>{{ school.mes }}</p>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      text: "",
      school: [],
    };
  },
  components: {},
  methods: {
    tijiao() {
      console.log(localStorage.user == undefined);
      console.log(localStorage.user );
      this.ajax({
        method: "post",
        url: "/queryLogin",
        data: {
          name: this.text,
        },
      })
        .then((res) => {
          console.log(res);
          this.school = res.data;
          localStorage.user = JSON.stringify(res.data);
        })
        .catch((res) => {
          this.school = res.data;
        });
    },
    created() {
      console.log(localStorage.user == undefined);
    },
  },
};
</script>
